package com.pi.pro.xcmg.am.common.vo.act;

import com.pi.common.CodesConstants;
import com.pi.common.utils.StringUtils;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 *
 */
@Getter
@Setter
public class PickLabelDto implements Serializable{

    private String materialcode;
    private String materialname;
    private String unitcode;
    private BigDecimal quantity;
    private String uloc;
    private String lotnumber;
    private String sloc;

    private String printer;


    public String toJsonData(){
        StringBuffer buf=new StringBuffer();

        if (quantity==null){
            quantity=BigDecimal.ZERO;
        }
        //String printdata = this.barcode;
        String barcodetext=this.materialcode;

        //      '{"MAT_CODE":"2030605001","MAT_NAME":"KR1440机内线缆","MAT_SPEC":"HF902110","QTY":"100","SUPPLIER_NAME":"广州洋钒电子科技有限公司","LOTNUM":"20230601","MAT_BARCODE":"2030605001,06057,230607,1"}',
        buf.append("{");
        buf.append("\"MAT_BARCODE\":").append("\"").append(barcodetext).append("\",");

        buf.append("\"MAT_CODE\":").append("\"").append(StringUtils.avoidNull(this.materialcode)).append("\",");
        buf.append("\"MAT_NAME\":").append("\"").append(StringUtils.avoidNull(this.materialname)).append("\",");

        buf.append("\"LOTNUMS\":").append("\"").append(StringUtils.avoidNull(this.lotnumber)).append("\",");
        buf.append("\"PICK_QTY\":");
        if ((this.quantity==null) || (this.quantity.compareTo(BigDecimal.ZERO)<=0)){
            buf.append("\"\"");
        }else {
            buf.append("\"").append(this.quantity.stripTrailingZeros().toPlainString()).append("\"");
        }
        buf.append(",");
        buf.append("\"UNIT_CODE\":").append("\"").append(StringUtils.ifNullOrBlank(this.unitcode, CodesConstants.UOM_EACH)).append("\",");
        buf.append("\"ULOC\":").append("\"").append(StringUtils.avoidNull(this.uloc)).append("\",");
        buf.append("\"SLOC\":").append("\"").append(StringUtils.avoidNull(this.sloc)).append("\"");
        buf.append("}");

        return buf.toString();
    }
}
